package com.nut.article.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nut.article.api.req.SaveSortReq;
import com.nut.article.common.Result;
import com.nut.article.entity.Article;
import com.nut.article.entity.ArticleVo;
import com.nut.article.entity.Tag;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

public interface ArticleService {

    String sideList = "sideList";
    String hotList = "hotList";
    String topList = "topList";
    String newList = "newList";

    String TOP = "top";
    String HOT = "hot";
    String SIDE = "side";

    //获取下载信息
    Result<String> getDownInfoById(Serializable id);

    //获取热门排行榜  头部5个
    List<ArticleVo> hotList();

    //获取置顶文章
    List<ArticleVo> topList();

    //获取最新文章
    List<ArticleVo> newList();

    //获取推荐排行榜  侧边栏
    List<ArticleVo> sideList();

    List<ArticleVo> searchList(String word);

    Result saveSort(SaveSortReq saveSortReq);

    /**
     * 文章点赞 或 取消
     * @param id     文章id
     * @param action 1点赞  0取消点赞
     * @return
     */
    Result doLikes(Integer id, Integer action);

    //根据tag获取文章
    Result<IPage<ArticleVo>> getByTag(Integer tagId, Integer pageNo, Integer pageSize);

    //清理缓存
    Result cleanCache();

    Result<IPage<Article>> list(String name, Integer categoryId, Integer status, Integer pageNo, Integer pageSize);

    Result<Article> getById(Serializable id);

    /**
     * 获取文章下载信息
     * @param id
     * @param code
     * @return
     */
    Result<String> getDownloadInfoById(Serializable id,String code);

    Result add(Article article);

    Result updateById(Article article);

    Result deleteByIds(Set<Integer> ids);

    /**
     * 设置获取文章的验证码
     * @param code
     * @return
     */
    Result setCode(String code);

    Result getCode();

}
